package com.cms.recursoshumanos.activity.user.poliza.hospital;

import com.example.frontendrecursoshumanos.R;
import com.cms.recursoshumanos.activity.main.MainRecursosHumanosActivity;
import com.cms.recursoshumanos.cache.UserInfoCache;
import com.cms.recursoshumanos.object.Hospital;

import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class DetailHospitalActivity extends MainRecursosHumanosActivity {

	private static Hospital elHospital;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_detail_hospital);
		
		Bundle bundle = getIntent().getExtras();
		int id_hospital = Integer.parseInt(bundle.getString("id_hospital"));
		elHospital = UserInfoCache.getInstance().getPoliza().getSeguro().getListadoHospital().getHospitalById(id_hospital);
		
		setComponents();
	}
	
	
	
	private void setComponents()
	{
		LinearLayout layout_info_general = (LinearLayout) findViewById(R.id.llInformacionGeneral);
		RelativeLayout layout_hospital_portrait = (RelativeLayout) findViewById(R.id.rlHospitalPortrait);
		
		TextView nombre_hospital = (TextView) layout_hospital_portrait.findViewById(R.id.tvPortaitNombreHospital);
		
		TextView rif_hospital_second_row = (TextView) layout_info_general.findViewById(R.id.tvValueRifHospital);
		TextView telefono1_hospital_second_row = (TextView) layout_info_general.findViewById(R.id.tvValueTelefono1Hospital);
		TextView telefono2_hospital_second_row = (TextView) layout_info_general.findViewById(R.id.tvValueTelefono2Hospital);
		TextView direccion_hospital_second_row = (TextView) layout_info_general.findViewById(R.id.tvValueDireccionHospital);
		TextView persona_contacto_hospital_second_row = (TextView) layout_info_general.findViewById(R.id.tvValuePersonaContactoHospital);

		
		//*--------------Seteo de Portait------------------------------------
		nombre_hospital.setText(elHospital.getNombre_Hospital());
		
		//*--------------Seteo de Detalle------------------------------------
		rif_hospital_second_row.setText(elHospital.getRif_Hospital());
		telefono1_hospital_second_row.setText(elHospital.getTelefono_Hospital_1());
		
		LinearLayout llNroTele2Hos = (LinearLayout) findViewById(R.id.trTelefono2Hospital);
		if (elHospital.getTelefono_Hospital_2() != null)
		{
			llNroTele2Hos.setVisibility(View.VISIBLE);
			telefono2_hospital_second_row.setText(elHospital.getTelefono_Hospital_2());
		}
		else
		{
			llNroTele2Hos.setVisibility(View.GONE);
		}
		direccion_hospital_second_row.setText(elHospital.getDireccionHospital());
		
		LinearLayout llPersonaContacto = (LinearLayout) findViewById(R.id.trPersonaContactoHospital);
		if (elHospital.getNombre_Persona_Contacto() != null)
		{
			persona_contacto_hospital_second_row.setText(elHospital.getNombre_Persona_Contacto());
			llPersonaContacto.setVisibility(View.VISIBLE);
		}
		else
		{
			llPersonaContacto.setVisibility(View.GONE);
		}
		
		
		
	}

}
